#pragma once

#include <exception>
#include <pthread.h>
#include <semaphore.h>

/**
 * semaphore
*/
class Sem 
{
public:
    Sem();
    Sem(int num);
    ~Sem();

    bool wait();
    bool post();
private:
    sem_t sem_;
};

/**
 * mutex
*/
class Locker 
{
public:
    Locker();
    ~Locker();

    bool lock();
    bool unlock();
    pthread_mutex_t *get();
private:
    pthread_mutex_t mutex_;
};

/**
 * condition_variable
*/
class Cond
{
public:
    Cond();
    ~Cond();

    bool wait(pthread_mutex_t *mutex);
    bool timewait(pthread_mutex_t *mutex, struct timespec t);
    bool signal();
    bool broadcast();
private:
    pthread_cond_t cond_;

};

